package com.jwthhealth_pub.wristband.view;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.common.base.BaseActivity;
import com.jwthhealth_pub.common.view.TitleLayout;
import com.jwthhealth_pub.wristband.view.widget.MyRingView;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.jwthhealth_pub.common.LogUtil.makeLogTag;

/**
 * 手环 运动记录
 * Created by yang on 2017/12/26.
 */

public class StartSportActivity extends BaseActivity {

    private final String TAG = makeLogTag(StartSportActivity.class);

    @BindView(R.id.title_layout)
    TitleLayout titleLayout;
    @BindView(R.id.myRingView)
    MyRingView myRingView;
    @BindView(R.id.rgChannel)
    RadioGroup rgChannel;
    @BindView(R.id.rb_walk)
    RadioButton rb_walk;
    @BindView(R.id.rb_running)
    RadioButton rb_running;
    @BindView(R.id.rb_bike)
    RadioButton rb_bike;
    @BindView(R.id.tv_backgroundType)
    TextView tv_backgroundType;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start_sport);
        ButterKnife.bind(this);
        initView();

    }

    private void initView() {
        myRingView.setStyle(getResources().getColor(R.color.sportStart), false);
        rgChannel.setOnCheckedChangeListener(
                new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group,
                                                 int checkedId) {
                        switch (checkedId) {
                            case R.id.rb_walk:
                                tv_backgroundType.setBackground(getResources().getDrawable(R.mipmap.sport_walk));
                                rb_walk.setChecked(true);
                                break;
                            case R.id.rb_running:
                                tv_backgroundType.setBackground(getResources().getDrawable(R.mipmap.sport_running));
                                break;
                            case R.id.rb_bike:
                                tv_backgroundType.setBackground(getResources().getDrawable(R.mipmap.sport_bike));
                                break;
                            default:
                                break;
                        }
                    }
                });
    }

    @Override
    protected void title() {
        titleLayout.setOnTitleLayoutListener(new TitleLayout.TitleLayoutListener() {
            @Override
            public void leftclick() {
                finish();
            }

            @Override
            public void leftTextClick() {

            }

            @Override
            public void rightclick() {

            }

            @Override
            public void rightTextClick() {

            }
        });
    }
}
